//package com.xqboss.chain.bsn;
//
//
//import com.alibaba.fastjson2.JSONObject;
//import com.reddate.wuhanddc.DDCSdkClient;
//import com.reddate.wuhanddc.dto.wuhanchain.RespJsonRpcBean;
//import com.reddate.wuhanddc.dto.wuhanchain.TransactionsBean;
//import com.reddate.wuhanddc.listener.SignEventListener;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.web3j.protocol.core.methods.response.TransactionReceipt;
//
//import java.math.BigInteger;
//
//@Slf4j
//@Component
//public class BaseServiceUtil {
//
//
//    /**
//     * 获取交易回执
//     *
//     * @param txHash
//     * @return
//     */
//    public TransactionReceipt getTransactionReceipt(String txHash){
//        SignEventListener signEventListener = event -> AuthorityServiceUtil.transactionSignature(event.getSender(), event.getRawTransaction());
//        DDCSdkClient ddcSdkClient = DDCSdkClient.builder().setSignEventListener(signEventListener).build();
//        TransactionReceipt receipt = null;
//        try {
//            receipt = ddcSdkClient.baseService.getTransactionReceipt(txHash);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        log.info("getTransactionReceipt:::" + JSONObject.toJSONString(receipt));
//        return receipt;
//    }
//
//    public TransactionsBean getTransactionByHash(String txHash) throws Exception {
//        SignEventListener signEventListener = event -> AuthorityServiceUtil.transactionSignature(event.getSender(), event.getRawTransaction());
//        DDCSdkClient ddcSdkClient = DDCSdkClient.builder().setSignEventListener(signEventListener).build();
//        TransactionsBean ethTransaction = ddcSdkClient.baseService.getTransactionByHash(txHash);
//        log.info(JSONObject.toJSONString(ethTransaction));
//        return ethTransaction;
//    }
//
//    public BigInteger getGasPrice() throws Exception {
//        SignEventListener signEventListener = event -> AuthorityServiceUtil.transactionSignature(event.getSender(), event.getRawTransaction());
//        DDCSdkClient ddcSdkClient = DDCSdkClient.builder().setSignEventListener(signEventListener).build();
//        BigInteger gasPrice = ddcSdkClient.baseService.getGasPrice();
//        log.info(String.valueOf(gasPrice));
//        return gasPrice;
//    }
//
//    public RespJsonRpcBean getBlockByNumber(BigInteger blockByNumber) throws Exception {
//        SignEventListener signEventListener = event -> AuthorityServiceUtil.transactionSignature(event.getSender(), event.getRawTransaction());
//        DDCSdkClient ddcSdkClient = DDCSdkClient.builder().setSignEventListener(signEventListener).build();
//        RespJsonRpcBean receipt = ddcSdkClient.baseService.getBlockByNumber(blockByNumber);
//        log.info(JSONObject.toJSONString(receipt));
//        return receipt;
//    }
//
//
//    /**
//     * 获取最新的nonce
//     * @param address 终端用户地址
//     * @return
//     * @throws Exception
//     */
//    public BigInteger getTransactionCount(String address) throws Exception {
//        SignEventListener signEventListener = event -> AuthorityServiceUtil.transactionSignature(event.getSender(), event.getRawTransaction());
//        DDCSdkClient ddcSdkClient = DDCSdkClient.builder().setSignEventListener(signEventListener).build();
//        BigInteger nonce = ddcSdkClient.baseService.getTransactionCount(address);
//        log.info(String.valueOf(nonce));
//        return nonce;
//    }
//
////
////
////    @Test
////    void getBlockByNumberByOptions() throws Exception {
////        RespJsonRpcBean receipt = ddcSdkClient.baseService.getBlockByNumber(new BigInteger("1794559"));
////        log.info(JSONObject.toJSONString(receipt));
////    }
////
////
////    public BigInteger getBlockNumber() throws Exception {
////        SignEventListener signEventListener = event -> null;
////        DDCSdkClient ddcSdkClient = new DDCSdkClient().instance(signEventListener);
////        BigInteger blockNumber = ddcSdkClient.baseService.getBlockNumber();
////        log.info(String.valueOf(blockNumber));
////        return blockNumber;
////    }
////
////    @Test
////    void getTransByStatus() throws Exception {
////        boolean status = ddcSdkClient.baseService.getTransStatusByHash("0xb602c3187c41bf9041141c95ce373b5455662768eaf16338713f113d742b7147");
////        log.info(String.valueOf(status));
////    }
//}